#@adminLayout() #define main()

<body class="white-bg">
	<div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-edit" >
			<input id="pcode" name="pcode"  type="hidden"  />
			<div class="form-group">
				<label class="col-sm-2 control-label">部门代码：</label>
				<div class="col-sm-10">
					<input type="text" name="ccode" class="form-control" readonly/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">部门名：</label>
				<div class="col-sm-10">
					<input type="text" name="cname" class="form-control" required maxlength="100"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">层级：</label>
				<div class="col-sm-10">
					<input type="text" id="ilayer" name="ilayer" class="form-control" readonly/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">部门级别：</label>
				<div class="col-sm-10">
					<select class="form-control" name="cgroup" >
						<option value="">无</option>
						<option value="1">上级部门</option>
						<option value="2">工作部门</option>
						<option value="3">班组部门</option>
					</select>
					<!-- <input type="text" name="cgroup" class="form-control" required maxlength="22"/> -->
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">主管领导：</label>
				<div class="col-sm-10">
					<select class="form-control" name="m_leader" >
						<option value="">无</option>
						<option v-for="(item,i) in leaderlist" :value="item.ccode" >{{item.cname}}</option>
					</select>
					<!-- <input type="text" name="m_leader" class="form-control" maxlength="255"/> -->
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">序号：</label>
				<div class="col-sm-10">
					<input type="text" id="isort" name="isort" class="form-control" value="1"/>
				</div>
			</div>
		</form>
	</div>
	<script type="text/javascript">
		var prefix = "#(ctx)/sysorg";
		var ccode='#(ccode)';
		var pcode='#(pcode)';
		var ilayer='#(ilayer)';
		var c_pro='#(c_pro)';
		
    	$(function(){
    		$("#form-edit").validate({
    			onkeyup: false,
    			rules:{
    				isort:{
    					number:true
    				}
    			},
    		    focusCleanup: true
    		});
    		
    		$('#ccode').val(ccode);
    		if(ccode=='')		//新增
    		{
    			$('#ilayer').val(ilayer);
    		}
    		
    		if(pcode!='')
    		{
        		$('#pcode').val(pcode);
    		}
			$('#form-edit').loadForm(prefix+'/getData?ccode='+ccode+'&c_pro='+c_pro);
    	});
    	
		function submitHandler() {
	        if ($.validate.form()) {
	        	var data=$('#form-edit').serializeArray();
	        	data.push({"name":"c_pro","value":c_pro});
	        	$.operate.save(prefix + "/save", data);
	        }
	    }
		

	    var app = new Vue({
	    	  el: '#app',
	    	  data: {
	    		  leaderlist:[],
	    	  },
			mounted:function() {
				this.getLeadList();
			},
	    	  methods: {
	    		  getLeadList(){
	    			 var that=this;
	  				axios.get(prefix+"/getLeadList",
	  					{
	  						params:{
	  							ccode : ccode,
	  							c_pro:c_pro
	  						}
	  					}).then(function (res){
	  					that.leaderlist=res.data;
	  				});
	    		  },
	    	 }
	    });
	</script>
</body>
#end
